package com.cqc.manage.error.tokenerror;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
public class ErrorTokenControllerAvice {

    private static Logger LOG = LoggerFactory.getLogger(ErrorTokenControllerAvice.class);
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public ResponseEntity handleException(Exception e){
        LOG.error("异常信息:{}",e.getMessage());
        HashMap<String, Object> attrs = new HashMap<>();
        String errorMessage = e.getMessage();
        attrs.put("message",errorMessage);
        attrs.put("code","202");
        return new ResponseEntity(attrs, HttpStatus.INTERNAL_SERVER_ERROR);
    }
}
